
const fastifyPlugin = require('fastify-plugin')

async function auth(fastify, options, done) {
  fastify.decorate('auth', (request, reply) => {

    const { name } = request.query
    const { token } = request.headers

    // 验证登录程序
    if (!token) {
      reply.send({
        code: -2,
        msg: 'login false'
      })
    }

    console.log(token)

    // 返回 false 或者 user_info
    return true
  })
  done()
}

module.exports = fastifyPlugin(auth)